package com.javacoo.xservice.base.setting;

import java.util.Map;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import com.javacoo.xservice.base.bean.SecurityBean;

/**
 * 应用相关基础配置
 * <p>说明:</p>
 * <li>对应application-*.properties中app.config.core</li>
 * @author DuanYong
 * @since 2017年7月28日上午9:02:32
 */
@Component
@ConfigurationProperties(prefix = "app.config.core")
public class AppCoreSetting {
	/** 是否开启安全验证,默认值*/
	public static final Boolean DEFAULT_VALIDATE = true;
	/** 是否开启签名验证,默认值*/
	public static final Boolean DEFAULT_SIGN = true;
	/** 是否开启授权验证,默认值*/
	public static final Boolean DEFAULT_AUTH = true;
	/** 需要验证用户是否授权的接口集合,默认值*/
	public static final String DEFAULT_AUTH_USER_LIST = "";
	/** 需要验证设备是否授权的接口集合,默认值*/
	public static final String DEFAULT_AUTH_DEVICE_LIST = "";
	/** 是否开启返回数据签名,默认值*/
	public static final Boolean DEFAULT_RESP_SIGN = true;
	/** Mapper扫描配置,默认值*/
	public static final String DEFAULT_SCAN_PACKAGE = "com.javacoo.xservice.example.**.dao";
	/** 接口访问允许误差,默认值*/
	public static final Long DEFAULT_API_ACCESS_ALLOW_TIME = 1800000L;
	/** 是否开启请求限制,默认值*/
	public static final Boolean DEFAULT_REQ_LIMIT_ENABLED = false;
	/** 请求限制:每秒允许最大并发限制,默认值*/
	public static final Integer DEFAULT_REQ_LIMIT_MAX = 300;
    /** 包含的路径,默认值*/
    public static final String DEFAULT_INCLUDE_PATH_PATTERNS = "/**";
    /** 排除的路径,默认值*/
    public static final String DEFAULT_EXCLUDE_PATH_PATTERNS = "";
    /** 允许上传的文件类型,默认值*/
    public static final String DEFAULT_UPLOAD_SUFFIX = "jpg,png,ico,bmp,jpeg,pdf,xls,xlsx.doc,docx";
    /** 参数,默认值*/
    public static final String DEFAULT_UPLOAD_FILE_PARAM_KEY = "param";
	
	/** 是否开启安全验证:true->开启,false->关闭*/
	private Boolean validate = DEFAULT_VALIDATE;
	/** 是否开启签名验证:true->开启,false->关闭*/
	private Boolean sign = DEFAULT_SIGN;
	/** 是否开启授权验证:true->开启,false->关闭*/
	private Boolean auth = DEFAULT_AUTH;
	/**需要验证用户是否授权的接口集合,多个以逗号分隔*/
	private String authUserList = DEFAULT_AUTH_USER_LIST;
	/**需要验证设备是否授权的接口集合,多个以逗号分隔*/
	private String authDeviceList = DEFAULT_AUTH_DEVICE_LIST;
	/** 是否开启返回数据签名:true->开启,false->关闭*/
	private Boolean respSign = DEFAULT_RESP_SIGN;
	/** Mapper扫描配置*/
	private String scanPackage = DEFAULT_SCAN_PACKAGE;
	/** 接口访问允许误差*/
	private Long apiAccessAllowTime = DEFAULT_API_ACCESS_ALLOW_TIME;
	/** 是否开启请求限制:true->开启,false->关闭*/
	private Boolean reqLimitEnabled = DEFAULT_REQ_LIMIT_ENABLED;
	/** 请求限制:每秒允许最大并发限制*/
	private Integer reqLimitMax = DEFAULT_REQ_LIMIT_MAX;
    /**安全对象Map*/
    private Map<String, SecurityBean> securityMap;
    /**包含的*/
    private String includePathPatterns = DEFAULT_INCLUDE_PATH_PATTERNS;
    /**排除的*/
    private String excludePathPatterns = DEFAULT_EXCLUDE_PATH_PATTERNS;
    /**允许上传的文件类型*/
    private String suffixList = DEFAULT_UPLOAD_SUFFIX;

    public Boolean getValidate() {
        return validate;
    }

    public void setValidate(Boolean validate) {
        this.validate = validate;
    }

    public Boolean getSign() {
        return sign;
    }

    public void setSign(Boolean sign) {
        this.sign = sign;
    }

    public Boolean getAuth() {
        return auth;
    }

    public void setAuth(Boolean auth) {
        this.auth = auth;
    }

    public String getAuthUserList() {
        return authUserList;
    }

    public void setAuthUserList(String authUserList) {
        this.authUserList = authUserList;
    }

    public String getAuthDeviceList() {
        return authDeviceList;
    }

    public void setAuthDeviceList(String authDeviceList) {
        this.authDeviceList = authDeviceList;
    }

    public Boolean getRespSign() {
        return respSign;
    }

    public void setRespSign(Boolean respSign) {
        this.respSign = respSign;
    }

    public String getScanPackage() {
        return scanPackage;
    }

    public void setScanPackage(String scanPackage) {
        this.scanPackage = scanPackage;
    }

    public Long getApiAccessAllowTime() {
        return apiAccessAllowTime;
    }

    public void setApiAccessAllowTime(Long apiAccessAllowTime) {
        this.apiAccessAllowTime = apiAccessAllowTime;
    }

    public Boolean getReqLimitEnabled() {
        return reqLimitEnabled;
    }

    public void setReqLimitEnabled(Boolean reqLimitEnabled) {
        this.reqLimitEnabled = reqLimitEnabled;
    }

    public Integer getReqLimitMax() {
        return reqLimitMax;
    }

    public void setReqLimitMax(Integer reqLimitMax) {
        this.reqLimitMax = reqLimitMax;
    }

    public Map<String, SecurityBean> getSecurityMap() {
        return securityMap;
    }

    public void setSecurityMap(Map<String, SecurityBean> securityMap) {
        this.securityMap = securityMap;
    }

    public String getIncludePathPatterns() {
        return includePathPatterns;
    }

    public void setIncludePathPatterns(String includePathPatterns) {
        this.includePathPatterns = includePathPatterns;
    }

    public String getExcludePathPatterns() {
        return excludePathPatterns;
    }

    public void setExcludePathPatterns(String excludePathPatterns) {
        this.excludePathPatterns = excludePathPatterns;
    }

    public String getSuffixList() {
        return suffixList;
    }

    public void setSuffixList(String suffixList) {
        this.suffixList = suffixList;
    }
}
